import React, {Component} from "react";
import {Form, Input} from 'antd';
import PropTypes from "prop-types";

const Item = Form.Item;

class AddForm extends Component{
    static propTypes = {
        setForm: PropTypes.func.isRequired,
    };

    componentWillMount() {
        this.props.setForm(this.props.form)
    }

    render() {
        const { getFieldDecorator } = this.props.form;
        const formItemLayout = {
            labelCol: { span: 4 },
            wrapperCol: { span: 18 },
        };

        return (
            <Form {...formItemLayout} >
                <Item label='角色名称：'>
                    {
                        getFieldDecorator('roleName', {
                            rules: [
                                { required: true, whitespace: true, message: '请输入角色名称' }
                            ],
                            initialValue: ''
                        }) (
                            <Input placeholder='请输入角色名称'/>
                        )
                    }
                </Item>
            </Form>
        );
    }
}

export default Form.create()(AddForm);